﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using System.Xml.Linq;
using PsychSurvey.ResearchId;
namespace PsychSurvey
{
    public class Global : System.Web.HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {
            // Get claims
            UserAuthenticate user = new UserAuthenticate(true);            
            ClaimView[] Claims = user.GetClaimList();
            dbDataContext db = new dbDataContext();            
            foreach (PsychSurvey.ResearchId.ClaimView myClaim in Claims)
            {
                Claim c = db.Claims.SingleOrDefault(x => x.ClaimId == myClaim.ClaimId);
                if (c == null)
                {
                    c = new Claim();
                    c.ClaimId = myClaim.ClaimId;
                    c.ClaimName = myClaim.ClaimName;
                    c.ClaimUrl = myClaim.ClaimUrl;
                    c.DataType = myClaim.DataType;
                    db.Claims.InsertOnSubmit(c);
                }
            }
            db.SubmitChanges();
        }

        protected void Session_Start(object sender, EventArgs e)
        {

        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {

        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {

        }

        protected void Session_End(object sender, EventArgs e)
        {

        }

        protected void Application_End(object sender, EventArgs e)
        {

        }
    }
}